import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

import org.eclipse.swt.events.PaintEvent;

/*** class boxes handles boxes ***/
public class Boxes {
	
	static HashMap<String, Box> boxes;
	
	//c'tor
	public Boxes(){
		boxes = new HashMap<String, Box>();
	}
	
	//adds box to map
	public void addBox(Box box){
		boxes.put(box.getName(), box);
	}
	
	//checks if box exists
	public  boolean exists(String name){return boxes.containsKey(name);}
	
	//returns box with given name
	public  Box getBox(String name){ return boxes.get(name);}
	
	//paints all boxes to canvas
	public void paint(PaintEvent e){

		//paint boxes
		Set<String> strings = boxes.keySet();
		Iterator<String> it = strings.iterator();
		while(it.hasNext()){
			boxes.get(it.next()).paint(e);
		}
	}

}
